package  
{
	import flash.display.Bitmap;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	/**
	 * ...
	 * @author Bruno Martins
	 */
	public class Carta extends Sprite
	{
		[Embed(source = '../assets/carta_interrogacao.png')] 
		public var CartaInterrogacaoClass:Class;
		public  var cartaInterrogacao: Bitmap = new CartaInterrogacaoClass();
		
		[Embed(source = '../assets/carta raio.png')] 
		public var CartaRaioClass:Class;
		public var cartaRaio: Bitmap = new CartaRaioClass();
		
		[Embed(source = "../assets/carta balao.png")]
		public var CartaBalaoClass:Class;
		public var cartaBalao:Bitmap = new CartaBalaoClass();
		
		[Embed(source = "../assets/carta coracao.png")]
		public var CartaCoracaoClass:Class;
		public var cartaCoracao:Bitmap = new CartaCoracaoClass();
		
		[Embed(source = "../assets/carta estrela.png")]
		public var CartaEstrelaClass:Class;
		public var cartaEstrela:Bitmap = new CartaEstrelaClass();
		
		[Embed(source = "../assets/carta losango.png")]
		public var CartaLosangoClass:Class;
		public var cartaLosango: Bitmap = new CartaLosangoClass();
		
		[Embed(source = "../assets/carta pentagono.png")]
		public var CartaPentagonoClass:Class;
		public var cartaPentagono: Bitmap = new CartaPentagonoClass();
		
		[Embed(source = "../assets/carta quadrado.png")]
		public var CartaQuadradoClass:Class;
		public var cartaQuadrado: Bitmap = new CartaQuadradoClass();
		
		[Embed(source = "../assets/carta seta.png")]
		public var CartaSetaClass:Class;
		public var cartaSeta:Bitmap = new CartaSetaClass();
		
		[Embed(source = "../assets/carta triangulo.png")]
		public var CartaTrianguloClass:Class;
		public var cartaTriangulo:Bitmap = new CartaTrianguloClass();
		
		[Embed(source = "../assets/carta circulo.png")]
		public var CartaCirculoClass: Class;
		public var cartaCirculo: Bitmap = new CartaCirculoClass();
		
		private var ar_assets: Array = new Array();
		private var _escolhida: Boolean = false;
		private var _id: uint;
		
		
		public function Carta(cartaid: uint) 
		{	
			this._id = cartaid;
			carregarAssets();
			addChild(ar_assets[cartaid]);
			addChild(cartaInterrogacao);
			getChildAt(0).visible = false;
			this.addEventListener(MouseEvent.CLICK, click)
			buttonMode = true;
		}
		
		private function carregarAssets():void
		{
			ar_assets.push(cartaRaio, cartaBalao, cartaCoracao, cartaEstrela,
			cartaLosango, cartaPentagono, cartaQuadrado, cartaSeta, cartaTriangulo, cartaCirculo);
		}
		
		public function click(e: MouseEvent):void
		{	
			if (_escolhida)
			{
				_escolhida = false;
			}
			else
			{
				_escolhida = true;
			}
			trocarImagem(_escolhida);	
		}
		
		public function trocarImagem(escolhida: Boolean):void
		{
			getChildAt(0).visible = escolhida;
			getChildAt(1).visible = !escolhida;
			
			
		}
		
		public function get id():uint 
		{
			return _id;
		}
		
		public function get escolhida():Boolean 
		{
			return _escolhida;
		}
		
		public function set escolhida(value:Boolean):void 
		{
			_escolhida = value;
		}
		
	}

}